"use strict";
var _core = require("@pricking/core");
var _indexController = _interopRequireDefault(require("../base/IndexController"));
var _request = require("../../utils/request");
var _novelParser = _interopRequireDefault(require("../../services/novel-parser"));
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {
    var desc = {};
    Object.keys(descriptor).forEach(function(key) {
        desc[key] = descriptor[key];
    });
    desc.enumerable = !!desc.enumerable;
    desc.configurable = !!desc.configurable;
    if ("value" in desc || desc.initializer) {
        desc.writable = true;
    }
    desc = decorators.slice().reverse().reduce(function(desc, decorator) {
        return decorator ? decorator(target, property, desc) || desc : desc;
    }, desc);
    if (context && desc.initializer !== void 0) {
        desc.value = desc.initializer ? desc.initializer.call(context) : void 0;
        desc.initializer = undefined;
    }
    var own = Object.getOwnPropertyDescriptor(target, property);
    if (own && (own.get || own.set)) {
        delete desc.writable;
        delete desc.initializer;
    }
    if (desc.initializer === void 0) {
        Object.defineProperty(target, property, desc);
        desc = null;
    }
    return desc;
}
function _interopRequireDefault(obj) {
    return obj && obj.__esModule ? obj : {
        default: obj
    };
}
var _class, _dec, _dec1, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10;
var _dec11 = (0, _core).Controller('/v3/others');
let OthersController = _class = _dec11(((_class = class OthersController extends _indexController.default {
    async getApiDocHTML() {
        await this.ctx.render('api');
    }
    async getChapter() {
        this.ctx.success(this.novelService.supportedSites);
    }
    async getCatalog() {
        const { img  } = this.ctx.query;
        this.validator.required(img, '缺少必传的参数');
        const data = await (0, _request).craw(img);
        this.ctx.status = 200;
        this.ctx.type = 'image/png';
        this.ctx.body = data;
    }
    constructor(...args){
        super(...args);
        this.novelService = new _novelParser.default();
    }
}) || _class, _dec = (0, _core).Index([
    '/api-doc'
]), _dec1 = typeof Reflect !== "undefined" && typeof Reflect.metadata === "function" && Reflect.metadata("design:type", Function), _dec2 = typeof Reflect !== "undefined" && typeof Reflect.metadata === "function" && Reflect.metadata("design:paramtypes", []), _applyDecoratedDescriptor(_class.prototype, "getApiDocHTML", [
    _dec,
    _dec1,
    _dec2
], Object.getOwnPropertyDescriptor(_class.prototype, "getApiDocHTML"), _class.prototype), _dec3 = (0, _core).Get('/site-map'), _dec4 = (0, _core).Description('当前源'), _dec5 = typeof Reflect !== "undefined" && typeof Reflect.metadata === "function" && Reflect.metadata("design:type", Function), _dec6 = typeof Reflect !== "undefined" && typeof Reflect.metadata === "function" && Reflect.metadata("design:paramtypes", []), _applyDecoratedDescriptor(_class.prototype, "getChapter", [
    _dec3,
    _dec4,
    _dec5,
    _dec6
], Object.getOwnPropertyDescriptor(_class.prototype, "getChapter"), _class.prototype), _dec7 = (0, _core).Get('/get-image'), _dec8 = (0, _core).Description('获取图片资源'), _dec9 = typeof Reflect !== "undefined" && typeof Reflect.metadata === "function" && Reflect.metadata("design:type", Function), _dec10 = typeof Reflect !== "undefined" && typeof Reflect.metadata === "function" && Reflect.metadata("design:paramtypes", []), _applyDecoratedDescriptor(_class.prototype, "getCatalog", [
    _dec7,
    _dec8,
    _dec9,
    _dec10
], Object.getOwnPropertyDescriptor(_class.prototype, "getCatalog"), _class.prototype), _class)) || _class;
module.exports = OthersController;
